<template>
  <div>
    <div>
      {{username}}
    </div>

    <div>
      <input type="text" v-model="vname" />
    </div>
    <button @click="set()">设置name</button>

  </div>
</template>

<script lang="ts">
import { computed, ref } from "vue";
import { useStore } from "vuex";


export default {
  setup(){
    const vname =ref("")
    const store = useStore();
   const username = computed(() => store.state.userinfo.name);
   const set =()=>{
     store.dispatch("setName",vname.value)

   } 
    return {
        username,
        vname,
        set
    }
   


  }
}
</script>
